<template>
	<view class="container">
		<view class="white-cover">
		</view>
		<view class="cover">
		</view>
		<view class="content" :style="'height: '+contentHeight+'px;'">
			<!-- 个人 -->
			<!--未登录-->
			<view v-if="userInfo ==null||userInfo==undefined||userInfo==''||userInfo=='{}'">
				<!-- #ifdef APP-PLUS||H5 -->
				<view class="personal" style="position: relative;">
					<image @click="searviceTouched" class="serviceIcon" src="/static/my_icon_service.png"></image>
					<view @click="loginTouched">
						<image class="avature" src="@appstatic/my/my_icon_avatar_unlogin.png"></image>
						<view style="padding-left: 16px;float: left;">
							<view style="padding-top: 6px;">
								<text
									style="font-weight: 400;font-size: 14px;line-height: 20px;color: #ADB0AE;">未登录</text>
							</view>
							<view style="padding-top: 6px;">
								<text
									style="font-weight: 600;font-size: 16px;line-height: 22px;color: #3D3A3A;">注册/登录</text>
							</view>
						</view>
					</view>
					<view style="" @click="loginTouched">
						<image src="@appstatic/my/my_icon_link.png" mode=""
							style="width: 9.29px;height: 18px;margin-top: 24px;"></image>
					</view>

				</view>
				<!-- #endif -->

				<!-- #ifdef MP-WEIXIN -->
				<button class="button_personal" open-type='getPhoneNumber' @getphonenumber='getPhoneNumberconfidential'>
					<view class="view1">
						<image class="avature" src="@appstatic/my/my_icon_avatar_unlogin.png"></image>
						<view style="padding-left: 16px;float: left;">
							<view style="margin-top: 6px;">
								<text
									style="font-weight: 400;font-size: 14px;line-height: 20px;color: #ADB0AE;">未登录</text>
							</view>
							<view style="margin-bottom: 6px;">
								<text
									style="font-weight: 600;font-size: 16px;line-height: 22px;color: #3D3A3A;">注册/登录</text>
							</view>
						</view>
					</view>
					<view style="">
						<image src="@appstatic/my/my_icon_link.png" mode=""
							style="width: 9.29px;height: 18px;margin-top: 24px;"></image>
					</view>

				</button>
				<!-- #endif -->
			</view>


			<!--已登录-->
			<view v-else class="personal" style="position: relative;">
				<!-- #ifdef APP-PLUS||H5 -->
				<image @click="searviceTouched" class="serviceIcon" src="/static/my_icon_service.png"></image>
				<!-- #endif -->
				<!-- 六期签到 -->
				<!-- #ifdef APP-PLUS||H5 -->
				<image class="signImage" @click="toSignIn" v-if="isSign==1&&jumpToSign==true"
					src="https://dnsverify.pfmoto.com/appstatic/my/orderHome/signview_text.png">
				</image>
				<image class="signImage" v-else-if="isSign==1&&jumpToSign==false"
					src="https://dnsverify.pfmoto.com/appstatic/my/orderHome/signview_text.png">
				</image>
				<view class="signBgView" @click="toSignIn" v-else>
					<view class="signText">已连续签到{{checkinDay}}天</view>
				</view>
				<!-- #endif -->


				<view @click="toPersonal">
					<image class="avature" @error="imgerror"
						:src="userInfo.userimages||'@appstatic/my/my_icon_avatar_unlogin.png'">
					</image>
					<image class="avatar-bottom" src="@appstatic/my/my_icon_avatar_bottom.png" mode="">
					</image>
					<view style="float: left;">

						<view class='nameText' v-if="userInfo.wechatName==''||userInfo.wechatName==null">
							<view v-if="userInfo.phone==null||userInfo.phone==undefined">
								已注销用户
							</view>
							<view v-else>
								{{userInfo.phone.substr(0, 3) + '*****' + userInfo.phone.substr(8)}}
							</view>
						</view>
						<view class='nameText maxWidth' v-else>{{userInfo.wechatName}}</view>


						<view class="phoneText">
							{{userInfo.phone}}
						</view>
					</view>
				</view>
				<view @click="toPersonal">

					<image src="@appstatic/my/my_icon_link.png" mode=""
						style="width: 9.29px;height: 18px;margin-top: 24px;"></image>
				</view>
			</view>

			<!-- 三等分 -->
			<view class="number">
				<view class="post" @click="toPersonal">
					<view style="display: flex;align-items: center;justify-content: center;"><text
							class="num">{{publishNum}}</text></view>
					<view style="display: flex;align-items: center;justify-content: center;"><text class="cha">发布</text>
					</view>
				</view>
				<view class="following" @click="gotoFollowing">
					<view style="display: flex;align-items: center;justify-content: center;"><text
							class="num">{{myFocusCount}}</text></view>
					<view style="display: flex;align-items: center;justify-content: center;"><text class="cha">关注</text>
					</view>
				</view>
				<view class="follower" @click="gotoFollower">
					<view style="display: flex;align-items: center;justify-content: center;"><text
							class="num">{{focusMeCount}}</text></view>
					<view style="display: flex;align-items: center;justify-content: center;"><text class="cha">粉丝</text>
					</view>
				</view>
			</view>

			<view class="fun-list">

				<!-- #ifdef APP-PLUS||H5 -->

				<!--我的爱车-->
				<view class="row" @click="myLoveCarlist">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_myCar.png" mode="aspectFit">
						</image>

						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">我的爱车</text>
					</view>

					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>

				</view>

				<!--我的预约-->
				<!-- <view class="row" @click="myReservation">

					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_myReservation.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">试驾预约</text>
					</view>

					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view> -->

				<!--保养预约-->
				<!-- <view class="row" @click="maintainList">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_maintain.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">保养预约</text>
					</view>
					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view> -->
				<!--维修预约-->
				<!-- <view class="row" @click="repairList">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_repair.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">维修预约</text>
					</view>
					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view> -->
				
				<!-- 整合 我的预约 -->
				<view class="row" @click="myReservationAll">
				
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_myReservation.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">我的预约</text>
					</view>
				
					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>

				<!--心愿单-->
				<view class="row" @click="myWishlist">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_myWishlist.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">心愿单</text>
					</view>

					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>

				<!--我的订单-->
				<view class="row" @click="myOrderlist">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_myorderlist.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">我的订单</text>
					</view>
					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>

				<!--邀请好友 -六期-->
				<view class="row" @click="inviteFriends">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_inviting.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">邀请好友</text>
					</view>
					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>

				<!--我的积分-->
				<view class="row" @click="toMyIntegral">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_integral.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">我的积分</text>
					</view>
					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>


				<!--我的卡券-->
				<view class="row" @click="toMyCard">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_card.png" mode="aspectFit">
						</image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">我的卡券</text>
					</view>

					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>

				<!--我的徽章 六期-->
				<view class="row" @click="toMyBadge">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_badge.png" mode="aspectFit">
						</image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">我的徽章</text>
					</view>

					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>

				<!--我的发票-->
				<view class="row" @click="toMyBill">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_bill.png" mode="aspectFit">
						</image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">我的发票</text>
					</view>
					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>

				<!--设置-->
				<view class="row" @click="settingTouched">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_settingtouched.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">设置</text>
					</view>

					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>
				<!-- 联系我们 -->

				<view class="row" @click="contactMe()" style="margin-bottom: 50px;">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_callme.png"
							mode="aspectFit">
						</image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">联系我们</text>
					</view>
					<view class="left">
						<text lines="1" class="text-1" style="padding-left: 10px;color: #BDBDBD;"></text>
						<image class="arrow" style=" margin-left: 10px;height:12px;width:6.2px;"
							src="@appstatic/my/my_icon_smlink.png">
					</view>
				</view>
				<!-- #endif -->

				<!-- #ifdef MP-WEIXIN -->
				<!-- 我的资料 -->
				<view class="row" @click="myInformation" v-if="userInfo!==null&&userInfo!=''">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_my_info.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">我的资料</text>
					</view>
					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>
				<!--预约试驾-->
				<view class="row" @click="myReservation" v-if="userInfo!=null&&userInfo!=''">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_myReservation.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">预约试驾</text>
					</view>
					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>
				</view>
				<!--整车订单-->
				<view class="row" @click="WXmyOrderlist" v-if="userInfo!=null&&userInfo!=''">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_myorderlist.png"
							mode="aspectFit"></image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">整车订单</text>
					</view>
					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>

				</view>
				<!-- 联系我们 -->
				<view class="row" @click="callMe">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_callme.png"
							mode="aspectFit">
						</image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">联系我们</text>
					</view>
					<view class="left">
						<text lines="1" class="text-1" style="padding-left: 10px;color: #BDBDBD;">400-9991-778</text>
						<image class="arrow" style=" margin-left: 10px;height:12px;width:6.2px;"
							src="@appstatic/my/my_icon_smlink.png">
					</view>
				</view>
				<!--退出登录-->
				<view class="row" @click="logout" v-if="userInfo!=null&&userInfo!=''">
					<view class="left">
						<image style="width: 18px;height: 18px;" src="@appstatic/my/my_icon_logout.png"
							mode="aspectFit">
						</image>
						<text lines="1" class="text-1"
							style="font-weight: 400;font-size: 16px;line-height: 22px;padding-left: 18.25px;color: #3D3A3A;">退出登录</text>
					</view>

					<image style=" margin-left: 10px;height:12px;width:6.2px;" src="@appstatic/my/my_icon_smlink.png"
						class="arrow">
					</image>

				</view>

				<!-- #endif -->

			</view>
		</view>
	</view>
</template>

<script>
	// pages/my/my.js
	const app = getApp();
	const util = require("@utils/util.js");
	// import titlebar from "@/components/titlebar/titlebar";
	// import myShare from "@/components/myShare/myShare";
	// import contactUs from "@/components/contactUs/contactUs";
	const network = require("@manager/network-manager.js");
	const dialog = require("@utils/dialog.js");
	// #ifdef APP-PLUS
	const PluginModule = uni.requireNativePlugin("PluginModule");
	// #endif

	import {
		requestAndroidPermission,
		gotoAppPermissionSetting
	} from "@utils/permission.js"
	export default {
		data() {
			return {
				userInfo: null,
				showCall: false,
				funlistHeight: 230,
				isReadCount: 0,

				publishNum: 0,
				myFocusCount: 0,
				focusMeCount: 0,


				//小程序未登录用
				phoneNum: '',
				SessionKey: '',
				openid: '',
				encryptedData: '',
				iv: '',
				//小程序未登录用
				from: '',
				contentHeight: app.globalData.windowHeight - app.globalData.navigationBarHeight,
				isSign: 1,
				checkinDay: '0',
				jumpToSign: true,
				flag: false


			};
		},

		components: {
			// myShare,
			// contactUs
		},
		props: {},
		onLoad: function(options) {
			var that = this;
			//结束上一次监听
			uni.$off();
			//全局登录成功事件订阅，只要订阅了事件就可以收到值
			uni.$on("LOGIN_EVENT", async (res) => {
				console.log("LOGIN_EVENT:" + res);
				if (res) {
					console.log("登录成功");
					that.refreshData();
				} else {
					console.log("退出");
				}
			})
		},
		onShow: function(e) {
			this.refreshData();
			this.showSign()
		},
		onReady: function() {

		},
		methods: {
			refreshData: function() {
				console.log("refreshData")
				//#ifdef MP-WEIXIN
				console.log("onshow-MP-WEIXIN")
				this.getUnionid();
				this.from = uni.getStorageSync("from")
				//#endif

				//#ifdef APP-PLUS
				const clientInfo = plus.push.getClientInfo();
				console.log("clientInfo：" + JSON.stringify(clientInfo));
				//#endif
				this.userInfo = app.globalData.userInfo;

				if (this.userInfo == null || Object.keys(this.userInfo).length == 0) {
					this.myFocusCount = 0
					this.focusMeCount = 0
					this.publishNum = 0
				} else {
					this.loadCommunityData()
				}
				if (this.userInfo != null && this.userInfo != "" && this.userInfo.phone) {
					this.getUserWithMobile(this.userInfo.phone, "refrash")
				}
			},
			imgerror: function() {
				var _this = this
				_this.userInfo.userimages =
					"@appstatic/my/my_icon_avatar_unlogin.png"
			},
			//个人主页统计数据
			loadCommunityData: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_GET_PERSONAL_COMMUNITY_DATA;
				var params = {
					"loginId": app.getUserId()
				};

				network.get(uri, params, 'form').then(res => {

					if (res.code == 200) {
						that.myFocusCount = res.data.myFocusCount
						that.focusMeCount = res.data.focusMeCount
						that.publishNum = res.data.publishNum
					} else {
						// uni.showToast({
						// 	title: res.message?res.message:'获取失败',
						// 	duration: 3000,
						// 	icon: 'none'
						// })
					}
				}).catch(res => {
					console.error(res, 'err')
					// uni.showToast({
					// 	title: res.errMsg,
					// 	duration: 3000,
					// 	icon: 'none'
					// })
				});
			},
			contactMe: function() {
				var that = this;
				uni.showActionSheet({
					itemList: ['客服电话：4009991778', '在线客服'],
					success: function(res) {
						if (res.tapIndex == 0) {
							that.callMe();
						}
						if (res.tapIndex == 1) {
							that.searviceTouched();
						}
					},
					fail: function(res) {
						console.log(res.errMsg);
					}
				});
			},

			//联系我们
			callMe: function() {
				let platform = uni.getSystemInfoSync().platform; // 获取客户端信息，platform为ios/android
				//#ifdef APP
				if (plus.os.name == "iOS") {
					// 打电话
					uni.makePhoneCall({
						phoneNumber: '4009991778' //仅为示例
					});
				} else {
					const callPhone = requestAndroidPermission('android.permission.CALL_PHONE')
					console.log('callPhone' + callPhone)

					if (callPhone) {
						// 打电话
						uni.makePhoneCall({
							phoneNumber: '4009991778' //仅为示例
						});
					} else {
						console.log('false')
						uni.showModal({
							title: '提示',
							content: "请允许APP使用拨打电话和管理电话权限",
							success: function(res) {
								if (res.confirm) {
									gotoAppPermissionSetting()
								}
							}
						});
					}
				}
				//#endif
				//#ifdef MP-WEIXIN
				uni.makePhoneCall({
					// 手机号 这里可以直接写号码如 12345 也可以写获取号码的字段如this.mobile
					phoneNumber: "4009991778",
					// 成功回调
					success: (res) => {
						console.log('调用成功!')
					},
					// 失败回调
					fail: (res) => {
						console.log('调用失败!')
					}
				});
				//#endif

			},
			//退出登录
			logout: function() {
				app.saveUser(null);
				app.saveToken(null);
				// util.jumpLogin();
				this.userInfo = app.globalData.userInfo
				this.getUnionid();
				this.publishNum = 0
				this.myFocusCount = 0
				this.focusMeCount = 0
				uni.setStorageSync('openId', "")
				// uni.setStorageSync("loginSuccess", "");

			},
			//展示签到内容
			showSign: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_SYS_ADMIN_SHOWSIGN;
				var params = {};
				network.get(uri, params, 'form').then(res => {
					if (res.code == 200) {
						that.isSign = res.data.isSign
						that.checkinDay = res.data.checkinDay || '0'
					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}
				}).catch(res => {
					uni.showToast({
						title: res.errMsg,
						duration: 3000,
						icon: 'none'
					})
				});
			},
			//签到-用户app
			signInMethod: function() {
				var that = this;
				that.jumpToSign = false
				var uri = app.globalData.config.interfaces.URL_SYS_ADMIN_SIGNIN;
				var params = {};
				network.post(uri, params, 'form').then(res => {
					if (res.code == 200) {
						that.jumpToSign = true
						// uni.navigateTo({
						// 	url: '/module_my/pages/signIn/signIn'
						// });
						
						if (!this.flag) {
							this.flag = true
							uni.navigateTo({
								url: '/module_my/pages/signIn/signIn',
								success: () => {
									this.flag = false;
								},
								fail: () => {
									this.flag = false;
								}
							})
						}
						
						
						
						
						
						
						
						
						
						
						
						
						
						
						
					} else {
						that.jumpToSign = true
						uni.showToast({
							title: '签到失败',
							duration: 3000,
							icon: 'none'
						})
						// uni.navigateTo({
						// 	url: '/module_my/pages/signIn/signIn'
						// });
					}
				}).catch(res => {
					uni.showToast({
						title: res.errMsg,
						duration: 3000,
						icon: 'none'
					})
				});
			},

			//跳转签到
			toSignIn: function() {
				if (util.isLogin(getApp())) {
					if (this.isSign == 1) {
						this.signInMethod()
					} else {
						if (!this.flag) {
							this.flag = true
							uni.navigateTo({
								url: '/module_my/pages/signIn/signIn',
								success: () => {
									this.flag = false;
								},
								fail: () => {
									this.flag = false;
								}
							})
						}
					}
				} else {
					util.jumpLogin();
				}
			},
			//我的资料
			myInformation: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/myEdit/myEdit'
					});
				} else {
					util.jumpLogin();
				}
			},
			settingTouched: function() {
				uni.navigateTo({
					url: '/module_my/pages/setting/setting'
				})
			},
			loginTouched: function() {
				util.jumpLogin();
			},
			//跳转我的关注
			gotoFollowing: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/following'
					})
				} else {
					util.jumpLogin("following");
				}
			},
			//跳转粉丝
			gotoFollower: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/follower'
					})
				} else {
					util.jumpLogin("follower");
				}
			},
			//我的预约
			myReservation: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/myAppointment/myAppointment'
					})
				} else {
					util.jumpLogin("myAppointment");
				}
			},
			myReservationAll: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/myreservation/myreservation'
					})
				} else {
					util.jumpLogin("myAppointment");
				}
			},
			//心愿单
			myWishlist: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/wishList/wishList'
					})
				} else {
					util.jumpLogin("wishList");
				}
			},
			//我的订单
			myOrderlist: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						// url: '/module_my/pages/orderList/orderList'
						url: '/module_my/myorderHome/myorderHome'
					})
				} else {
					util.jumpLogin("myorderHome");
				}
			},
			//微信整车订单
			WXmyOrderlist: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/orderList/orderList'
					})
				} else {
					util.jumpLogin("orderList");
				}
			},
			//我的爱车
			myLoveCarlist: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_car/myCarList/myCarList'
					})
				} else {
					util.jumpLogin("myCarList");
				}
			},
			//保养预约
			maintainList: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/myMaintainList/myMaintainList?model=maintain'
					})
				} else {
					util.jumpLogin("myMaintainList");
				}
			},
			//维修预约
			repairList: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/myMaintainList/myMaintainList?model=repair'
					})
				} else {
					util.jumpLogin("myMaintainList1");
				}
			},
			//我的卡券
			toMyCard: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/myCardList/myCardList'
					})
				} else {
					util.jumpLogin("myCard");
				}
			},
			//我的徽章
			toMyBadge: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/myBadge/myBadge'
					})
				} else {
					util.jumpLogin("myCard");
				}
			},
			//我的发票
			toMyBill: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/setting/myBill'
					})
				} else {
					util.jumpLogin("myBill");
				}
			},
			//我的积分
			toMyIntegral: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/myPoints/myPoints'
					})
				} else {
					util.jumpLogin("myIntegral");
				}
			},

			//邀请好友
			inviteFriends: function() {
				// uni.showToast({
				// 	icon: "none",
				// 	title: "敬请期待"
				// })

				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/inviteFriends/inviteFriends'
					})
				} else {
					util.jumpLogin();
				}
			},
			//去个人中心
			toPersonal: function() {
				if (util.isLogin(getApp())) {
					uni.navigateTo({
						url: '/module_my/pages/personalCenter/personalCenter'
					})
				} else {
					util.jumpLogin("personalCenter");
				}
			},
			//微信小程序授权-获取SessionKey
			getUnionid: function() {
				wx.login({
					success: wxres => {
						console.log('code:' + wxres.code);

						var uri = app.globalData.config.interfaces.URL_WECHAT_GETUNIONID;

						var params = {
							"code": wxres.code,
						};
						network.get(uri, params, "form").then(res => {
							console.log(res);
							if (res.code == 200) {
								this.openid = res.data.openid;
								this.SessionKey = res.data.session_key;
								uni.setStorageSync('openId', this.openid)

							} else {
								uni.showToast({
									title: res.message,
									duration: 3000,
									icon: 'none'
								})
							}
						})
					}
				})
			},
			//微信小程序-未登录获取手机号(密)
			getPhoneNumberconfidential: function(e) {
				console.log(e.detail.errMsg == "getPhoneNumber:ok");
				if (e.detail.errMsg == "getPhoneNumber:ok") {
					this.encryptedData = e.detail.encryptedData
					this.iv = e.detail.iv
					this.getPhoneNumber()
				}
			},
			//微信小程序-未登录获取手机号
			getPhoneNumber: function() {

				var uri = app.globalData.config.interfaces.URL_WECHAT_GETUSERINFO;
				var params = {
					"encryptedData": this.encryptedData,
					"sessionkey": this.SessionKey,
					"iv": this.iv
				};
				network.post(uri, params, "form").then(res => {
					console.log(res);
					if (res.code == 200) {
						this.phoneNum = res.data.phoneNumber;
						this.getUserWithMobile(this.phoneNum, "login")
					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}
				})
			},
			//登录小程序-获取用户信息
			getUserWithMobile: function(mobile, use) {
				var params = {
					"phone": mobile
				};
				const header = {};
				var that = this;
				network.get(app.globalData.config.interfaces.URL_SYS_LOAD_USERINFO, params, "form", header).then(
					res => {
						if (res.code == 200) {

							if (use == "login") {
								if (res.data == null) {
									console.log(1)
									uni.navigateTo({
										url: "/pages/user/weChatLogin?mobile=" + mobile
									})
								} else {
									console.log(res.data)
									app.saveUser(res.data);
									//通过获取到的用户信息登录
									that.complete()
								}
							} else {
								app.saveUser(res.data);
							}




						} else {
							uni.showToast({
								title: res.message,
								duration: 3000,
								icon: 'none'
							})
						}
					}).catch(res => {
					console.log(res)
					uni.showToast({
						title: res.errMsg,
						duration: 3000,
						icon: 'none'
					})
					console.error(res);
				});
			},
			searviceTouched: function() {
				// uni.navigateTo({
				// 	url:"/pages/service/service"
				// })
				// #ifdef APP-PLUS
				PluginModule.startWebView({
					'title': '在线客服',
					'url': 'https://wpa1.qq.com/S92doXo6?_type=wpa&qidian=true&_pid=boqvjc.tgiohg.l6lkpmoi'
				}, res => {
					console.log(res)

				});
				// #endif
			},
			complete: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_WECHAT_GETAPPLOGINBYAUTO;
				var params = {
					"username": app.globalData.userInfo.userName,
					"sex": app.globalData.userInfo.sex,
					"wechatCountry": '',
					"wechatProvince": app.globalData.userInfo.wechatProvince,
					"wechatCity": app.globalData.userInfo.wechatCity,
					"phoneNumber": that.phoneNum,
					"isfrom": 3, //1.pc；2.移动端；3.小程序；4.app
					"openid": that.openid,
					"unionid": this.SessionKey

				};
				network.post(uri, params, "json").then(res => {
					console.log(res);
					if (res.code == 200) {
						app.saveToken(res.data.token);
						that.userInfo = app.globalData.userInfo
						uni.showToast({
							title: this.from
						})
						// this.$fire.$emit("loginSuccess");
						// uni.setStorageSync("loginSuccess", "loginSuccess");
						this.loadCommunityData()
						uni.showToast({
							title: "登录成功",
							duration: 3000,
							icon: 'none'
						})
					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}
				})
			},

		}
	};
</script>
<style scoped>
	.nameText {
		padding-top: 6px;
		font-weight: 600;
		font-size: 16px;
		line-height: 22px;
		color: #3D3A3A;
	}

	.phoneText {
		padding-top: 6px;
		font-weight: 400;
		font-size: 14px;
		line-height: 20px;
		color: #ADB0AE;
	}

	.container {
		background: top left no-repeat;
		background-image: url('@appstatic/my/my_icon_background.png');
		background-size: 270px, 357.43px;
		width: 100vw;
		height: 100vh;
	}

	/*渐变*/
	.cover {
		width: 100%;
		height: 217.38px;
		background: linear-gradient(180deg, #EA5404 0%, rgba(234, 84, 4, 0) 100%);
		opacity: 0.2;
		position: absolute;
		z-index: 1;
	}

	.white-cover {
		width: 100%;
		height: 297.38px;
		background: linear-gradient(0deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
		position: absolute;
		z-index: 2;
	}

	.container .content {
		width: 100%;
		height: 100%;
		z-index: 100;
		position: absolute;
	}

	.personal {
		display: flex;
		justify-content: space-between;
		flex-direction: row;
		padding-top: 88px;
		padding-left: 24px;
		padding-right: 31px;

	}

	.button_personal::after {
		border: none;
	}

	.button_personal {
		display: flex;
		justify-content: space-between;
		flex-direction: row;
		padding-left: 24px;
		padding-right: 31px;
		background-color: #00000000;
		align-items: center;
		text-align: center;
		margin-top: 88px;

	}

	.view1 {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.avature {
		float: left;
		width: 60px;
		height: 60px;
		border-radius: 60px;

	}

	.avatar-bottom {
		float: left;
		width: 14px;
		height: 14px;
		position: relative;
		right: 14px;
		top: 46.21px;

	}

	.number {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		padding-top: 30px;
		padding-bottom: 30px;
		padding-left: 54.5px;
		padding-right: 54.5px;
	}

	.num {
		font-weight: 600;
		font-size: 24px;
		line-height: 34px;
		color: #3D3A3A;
	}

	.cha {
		font-weight: 400;
		font-size: 12px;
		line-height: 17px;
		color: #ADB0AE;
	}

	/* 功能列表 */
	.fun-scroll {
		/* position: absolute;
	  top: 460rpx; */
	}

	.line {
		margin-top: 36rpx;
		border: 1px solid #ECEDEE;
		margin-left: 56rpx;
		margin-right: 44rpx;
	}

	.right {
		display: flex;
		align-items: center;
		flex-direction: row;
		color: #C4C4C4;
		font-size: 28rpx;
	}

	.fun-list {
		/* margin-top: 36rpx; */
		display: flex;
		flex-direction: column;
		padding-left: 34.25px;
		padding-right: 40.9px;
	}

	.fun-list .row {

		display: flex;
		vertical-align: middle;
		align-items: center;
		flex-direction: row;
		/* height: 105rpx; */
		height: 120rpx;
		position: relative;
		justify-content: space-between;

		/* margin-left: 56rpx;
	  margin-right: 28rpx; */
		/* color: #2d2d2d; */
		/* background-color: white; */
	}

	.rownoboder {
		border-bottom: 0rpx solid #EAEAEAFF !important;

	}

	.fun-list .row .left {
		display: flex;
		vertical-align: middle;
		align-items: center;
		flex-direction: row;
	}

	.fun-list .row .left image {
		width: 44rpx;
		height: 44rpx;
	}

	.fun-list .row .left text {
		font-size: 28rpx;
		line-height: 28rpx;
		color: #333333;
	}

	.fun-list .row .arrow {
		width: 48rpx;
		height: 48rpx;
		align-self: center
	}

	.logout {
		background: #FFD700;
		border: 1px solid #FFD700;
		box-sizing: border-box;
		border-radius: 6px;
		margin-left: 56rpx;
		margin-right: 56rpx;
		font-size: 32rpx;
		height: 90rpx;
		margin-top: 30rpx;
		line-height: 90rpx;
		text-align: center;
		margin-bottom: 30rpx;
		color: #333333;
	}

	.maxWidth {
		max-width: 200px;
	}

	.serviceIcon {
		right: 50upx;
		bottom: 120upx;
		position: absolute;
		width: 48upx;
		height: 48upx;
	}

	.signImage {
		bottom: 120upx;
		position: absolute;
		width: 221upx;
		height: 56upx;
		/* #ifdef APP-PLUS||H5 */
		right: 150upx;
		/* #endif */
		/* #ifdef MP-WEIXIN */
		right: 50upx;
		/* #endif */
	}

	.signBgView {
		bottom: 120upx;
		position: absolute;
		width: 221upx;
		height: 57rpx;
		display: flex;
		background-image: url('@appstatic/my/orderHome/signview_bg.png');
		background-size: 221rpx, 56rpx;
		background-repeat: no-repeat;
		/* #ifdef APP-PLUS||H5 */
		right: 150upx;
		/* #endif */
		/* #ifdef MP-WEIXIN */
		right: 50upx;
		/* #endif */

	}

	.signText {
		font-style: normal;
		font-weight: 400;
		align-items: center;
		font-size: 12px;
		line-height: 56upx;
		width: 221upx;
		text-align: center;
	}
</style>
